package unit5.part7;

public class SixteenNumberLogic implements NumberLogic {
    String a;
    String b;
    TenNumberLogic tenNumberLogic;

    public SixteenNumberLogic(String a, String b) {
        this.a = a;
        this.b = b;
        tenNumberLogic = new TenNumberLogic(sixteen2Ten(a), sixteen2Ten(b));
    }

    @Override
    public String plus() {
        return ten2Sixteen(tenNumberLogic.plus());
    }

    @Override
    public String multiply() {
        return ten2Sixteen(tenNumberLogic.multiply());
    }

    private String ten2Sixteen(String origin) {
        int i = Integer.parseInt(origin);
        return Integer.toHexString(i);
    }

    private int sixteen2Ten(String origin) {
        return Integer.parseInt(origin, 16);
    }
}
